# GDIR define
GDIR=../../../../

# MACIPATH define
MACIPATH=$(GDIR)/MaCI


# External includes
include $(GDIR)/GIMI/Makefile.gimi


# params
CC=gcc
CXX=g++
EXTRADEFS=-DLINUX_OS
MACIPATH=$(GDIR)/MaCI
UTILSPATH=$(GDIR)/utils
BUSPATH=$(MACIPATH)/bus
DRIVERPATH=$(MACIPATH)/drivers
MACIINTERFACEPATH=$(MACIPATH)/interfaces
INCLUDES=-I$(UTILSPATH) $(INCGIMI)
CFLAGS=-O0 -g3 -Wall $(INCLUDES) $(CE) \
	$(EXTRADEFS)
CPPFLAGS=-O0 -g3 -Wall $(INCLUDES) -Weffc++ $(EXTRADEFS)
LD=g++
LDFLAGS=
LIBS=-lrt -lpthread $(LIBSGIMI)


# Sources 'base' (required external links)
SRCSC=$(CGIMI) 
SRCSCPP=$(CPPGIMI)
VPATH=

# Construct final lists of CPP and C objects
OBJSC=$(SRCSC:.c=.o)
OBJSCPP=$(SRCSCPP:.cpp=.opp)

# Define COMPILE and LINK commands
COMPILEC=$(CC) $(CFLAGS) -c
COMPILECPP=$(CXX) $(CPPFLAGS) -c
LINK=$(LD) $(LDFLAGS)

.PHONY: all clean real-clean


all: MottiTask_standalone

###############################################
MottiTask_OBJECTS=MottiMission_main.opp MottiMission.opp \
	$(OBJSC) $(OBJSCPP)
MottiTask_standalone: $(MottiTask_OBJECTS)
	@$(LINK) -o $@ $(MottiTask_OBJECTS) $(LIBS)
	@echo "      [LD] $@"
##############################################
MottiTask_Generator_OBJECTS=MottiMission_Generator.opp MottiMission.opp \
	$(OBJSC) $(OBJSCPP)
MottiTask_Generator: $(MottiTask_Generator_OBJECTS)
	@$(LINK) -o $@ $(MottiTask_Generator_OBJECTS) $(LIBS)
	@echo "      [LD] $@"
##############################################

clean:
	@rm -f *.o *.opp *~
	@echo "      [CLEAN]"

real-clean realclean: clean
	@rm -f $(OBJSC) $(OBJSCPP)
	@echo "      [REAL-CLEAN]"

# Compile rule for all .o (.c) file
%.o:	%.c
	@$(COMPILEC) -o $@ $<
#	$(COMPILEC) -o $@ $<
	@echo "      [CC] $<"

# Compile rule for all .opp (.cpp) files
%.opp:	%.cpp
	@$(COMPILECPP) -o $@ $<
#	$(COMPILECPP) -o $@ $<
	@echo "      [CXX] $<"


